<template>
    <div v-if="signalsRadio1.title.title != undefined ">
        <div class="totalar" v-if="signalsRadio1.routerPush == 'search'">
            <div v-if="signalsRadio1.id == '1'">为您找到<span class="activeClor">{{ signalsRadio1.totals }}</span>条标讯</div>
            <div v-if="signalsRadio1.id == '2'">为您找到<span class="activeClor">{{ signalsRadio1.totals }}</span>家供应商</div>
            <div v-if="signalsRadio1.id == '3'">为您找到<span class="activeClor">{{ signalsRadio1.totals }}</span>家采购商</div>
            <div v-if="signalsRadio1.id == '4'">为您找到相关的品牌<span class="activeClor">{{ signalsRadio1.totals }}</span>个</div>
            <div v-if="signalsRadio1.id == '8'">为您找到<span class="activeClor">{{ signalsRadio1.totals }}</span>家公司</div>
            <div class="totalar_right">
                <div v-if="signalsRadio1.id == '1'">
                    <el-select v-model="arrange" class="m-2" style="width: 200px"
                        @change="summaries2">
                        <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </div>
                <div v-if="signalsRadio1.id == '2'">
                    <el-select v-model="summary" class="m-2" style="width: 200px"
                        @change="summaries1">
                        <el-option v-for="item in options1" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </div>
                <!-- signalsRadio1.pinaiID == '3' || -->
                <div v-if="signalsRadio1.id == '4'">
                    <el-select v-model="arrange" class="m-2" style="width: 200px"
                        @change="summaries3">
                        <el-option v-for="item in options3" :key="item.value" :label="item.label" :value="item.value" />
                    </el-select>
                </div>
                <div class="daochu1" @click="deriveClick"
                    v-if="signalsRadio1.id == '1'">
                    <img style="margin-right: 10px; width: 14px;height: 14px;" src="@/assets/img/mypoints/dc.png"
                        alt="">
                    导出
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRadio1Store } from "@/pain/search/search";
import { downloadFileByBase64 } from '@/utils/daochu/index'
import { Dataexportsupplier, Dataexportbuyer } from "@/Api/shoop/index";
const signalsRadio1 = useRadio1Store();
const summary = ref('1')
const arrange = ref('1')
const options1 = [
    {
        value: '1',
        label: '按中标总次数',
    },
    {
        value: '2',
        label: '按中标总金额',
    },
    {
        value: '3',
        label: '按最近一次中标时间',
    }
]

const options2 = [
    {
        value: '1',
        label: '按时间排序',
    },
    {
        value: '2',
        label: ' 按相似度排序',
    }
]
const options3 = [
    {
        value: '1',
        label: '按中标次数排序',
    },
    {
        value: '2',
        label: ' 按采购商数量排序',
    },
    {
        value: '3',
        label: ' 按代理商数量排序',
    }
]

const summaries1 = (data) => {
    summary.value = data
    signalsRadio1.summary.summary = data
    signalsRadio1.getsuppliers()
}

const summaries2 = (data) => {
    arrange.value = data
    signalsRadio1.arrange.arrange = data
    signalsRadio1.getsearchs()
}

const summaries3 = (data) => {
    arrange.value = data
    signalsRadio1.arrange.arrange = data
    signalsRadio1.getbrands();
}


const deriveClick = () => {
    // const today = new Date();
    // const year = today.getFullYear();
    // const month = today.getMonth() + 1;
    // const day = today.getDate();
    // const formattedDate = `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`;
    if (signalsRadio1.id == '1') {
        signalsRadio1.derive = true
    }

    // else if (signalsRadio1.id == '2') {
    //     let list = {
    //         ...signalsRadio1.title,
    //         ...signalsRadio1.suppliers
    //     }
    //     Dataexportsupplier(list).then(res => {
    //         downloadFileByBase64(res.data, 'application/vnd.ms-excel', `供应商${formattedDate}`);
    //     })
    // } else if (signalsRadio1.id == '3') {
    //     let list = {
    //         ...signalsRadio1.title,
    //         ...signalsRadio1.buyer
    //     }
    //     Dataexportbuyer(list).then(res => {
    //         downloadFileByBase64(res.data, 'application/vnd.ms-excel', `采购商${formattedDate}`);
    //     })
    // }
    // else if (signalsRadio1.id == '8') {

    // }
}
console.log(signalsRadio1.id)

</script>

<style lang="scss" scoped>
.activeClor {
    padding: 0 5px;
    color: #FF4848;
}

.totalar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    padding: 0 20px;
    background-color: #fff;

    .totalar_right {
        display: flex;
    }

    .daochu1 {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 90px;
        height: 30px;
        margin-left: 15px;
        font-size: 14px;
        border: 1px solid #6675FF;
        border-radius: 4px;
        color: #6675FF;
    }
}
</style>